package de.jmda.gen.java.impl;

import java.util.ArrayList;
import java.util.List;

import de.jmda.gen.Generator;
import de.jmda.gen.java.MethodModifiersGenerator;
import de.jmda.gen.java.ModifiersUtil;

/**
 * @author roger.jmda@gmail.com
 */
public class DefaultMethodModifiersGenerator
    extends AbstractModifiersGenerator implements MethodModifiersGenerator
{
	public final static Generator ABSTRACT     = dg(ModifiersUtil.ABSTRACT);
	public final static Generator SYNCHRONIZED = dg(ModifiersUtil.SYNCHRONIZED);
	public final static Generator NATIVE       = dg(ModifiersUtil.NATIVE);

	protected boolean bAbstract     = false;
	protected boolean bSynchronized = false;
	protected boolean bNative       = false;
	
	public DefaultMethodModifiersGenerator()
  {
	  super();
		
		setComponentSeparator(" ");
  }

	@Override
  public List<Generator> getGeneratorComponents()
  {
		List<Generator> result = new ArrayList<Generator>();
		
		if (bPublic      ) { result.add(PUBLIC); }
		if (bProtected   ) { result.add(PROTECTED); }
		if (bPrivate     ) { result.add(PRIVATE); }
		if (bFinal       ) { result.add(FINAL); }
		if (bStatic      ) { result.add(STATIC); }
		if (bAbstract    ) { result.add(ABSTRACT); }
		if (bSynchronized) { result.add(SYNCHRONIZED); }
		if (bNative      ) { result.add(NATIVE); }

		return result;
  }

	@Override
	public boolean isPublic()
  {
  	return bPublic;
  }

	@Override
	public void setPublic(boolean bPublic)
  {
  	this.bPublic = bPublic;

  	if (bPublic)
  	{
  		setPrivate(false);
  		setProtected(false);
  	}
  }

	@Override
	public boolean isProtected()
  {
  	return bProtected;
  }

	@Override
	public void setProtected(boolean bProtected)
  {
  	this.bProtected = bProtected;

  	if (bProtected)
  	{
  		setPublic(false);
  		setPrivate(false);
  	}
  }

	@Override
	public boolean isPrivate()
  {
  	return bPrivate;
  }

	@Override
	public void setPrivate(boolean bPrivate)
  {
  	this.bPrivate = bPrivate;

  	if (bPrivate)
  	{
  		setPublic(false);
  		setProtected(false);
  	}
  }

	@Override
	public boolean isFinal()
  {
  	return bFinal;
  }

	@Override
	public void setFinal(boolean bFinal)
  {
  	this.bFinal = bFinal;
  }

	@Override
	public boolean isStatic()
  {
  	return bStatic;
  }

	@Override
	public void setStatic(boolean bStatic)
  {
  	this.bStatic = bStatic;
  }

	@Override
	public boolean isNative()
  {
  	return bNative;
  }

	@Override
	public void setNative(boolean bNative)
  {
  	this.bNative = bNative;
  }

	@Override
  public boolean isAbstract()
  {
	  return bAbstract;
  }

	@Override
  public void setAbstract(boolean bAbstract)
  {
		this.bAbstract = bAbstract;
  }
}